package de.lighti.starcraft;

import java.nio.ByteBuffer;
import java.util.logging.Logger;

import de.lighti.starcraft.model.Match;

public class ClientEntry {
    public enum Status {
        READY, BUSY, AWAITNG_REPLY;
    }

    private final String name;

    private ByteBuffer messageBuffer;

    private int expectedMessageSize;

    private Status status;

    private Match currentMatch;

    private boolean isCurrentlyHost;

    private final static Logger LOGGER = Logger.getLogger( ClientEntry.class.getName() );

    public ClientEntry( String name ) {
        super();
        this.name = name;
    }

    public Match getCurrentMatch() {
        return currentMatch;
    }

    public int getExpectedMessageSize() {
        return expectedMessageSize;
    }

    public ByteBuffer getMessageBuffer() {
        return messageBuffer;
    }

    public Status getStatus() {
        return status;
    }

    public boolean isCurrentlyHost() {
        return isCurrentlyHost;
    }

    public void setCurrentlyHost( boolean isCurrentlyHost ) {
        this.isCurrentlyHost = isCurrentlyHost;
    }

    public void setCurrentMatch( Match currentMatch ) {
        this.currentMatch = currentMatch;
    }

    public void setExpectedMessageSize( int expectedMessageSize ) {
        this.expectedMessageSize = expectedMessageSize;
    }

    public void sethost( boolean b ) {
        isCurrentlyHost = b;

    }

    public void setMatch( Match m ) {
        currentMatch = m;

    }

    public void setMessageBuffer( ByteBuffer messageBuffer ) {
        this.messageBuffer = messageBuffer;
    }

    public void setStatus( Status status ) {
        if (this.status != status) {
            LOGGER.info( "Client " + this + " is now " + status );
        }
        this.status = status;
    }

    @Override
    public String toString() {
        return "Client [name=" + name + "]";
    }

}
